home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / nihcl-30.lha / nihcl-3.0 / lib / LookupKey.c < prev    next >
C/C++ Source or Header  |  1990-05-19  |  3KB  |  123 lines

  1. /* LookupKey.c -- implementation of Dictionary LookupKey
  2.  
  3.     THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
  4.     "UNITED STATES GOVERNMENT WORK".  IT WAS WRITTEN AS A PART OF THE
  5.     AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE.  THIS MEANS IT
  6.     CANNOT BE COPYRIGHTED.  THIS SOFTWARE IS FREELY AVAILABLE TO THE
  7.     PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
  8.     RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.
  9.  
  10. Author:
  11.     K. E. Gorlen
  12.     Bg. 12A, Rm. 2033
  13.     Computer Systems Laboratory
  14.     Division of Computer Research and Technology
  15.     National Institutes of Health
  16.     Bethesda, Maryland 20892
  17.     Phone: (301) 496-1111
  18.     uucp: uunet!nih-csl!kgorlen
  19.     Internet: kgorlen@alw.nih.gov
  20.     September, 1985
  21.  
  22. Function:
  23.     
  24. LookupKey is an abstract class for managing the key object of an Assoc.
  25. It is used to implement class Dictionary.
  26.  
  27. $Log:    LookupKey.c,v $
  28.  * Revision 3.0  90/05/20  00:20:09  kgorlen
  29.  * Release for 1st edition.
  30.  * 
  31. */
  32.  
  33. #include "LookupKey.h"
  34. #include "nihclIO.h"
  35.  
  36. #define    THIS    LookupKey
  37. #define    BASE    Object
  38. #define BASE_CLASSES BASE::desc()
  39. #define MEMBER_CLASSES
  40. #define VIRTUAL_BASE_CLASSES Object::desc()
  41.  
  42. DEFINE_CLASS(LookupKey,1,"$Header: /afs/alw.nih.gov/unix/sun4_40c/usr/local/src/nihcl-3.0/share/lib/RCS/LookupKey.c,v 3.0 90/05/20 00:20:09 kgorlen Rel $",NULL,NULL);
  43.  
  44. LookupKey::LookupKey(Object& newKey)
  45. {
  46.     akey = &newKey;
  47. }
  48.  
  49. Object* LookupKey::key() const { return akey; }
  50.  
  51. Object* LookupKey::key(Object& newkey)
  52. {
  53.     Object* temp = akey;
  54.     akey = &newkey;
  55.     return temp;
  56. }
  57.  
  58. bool LookupKey::isEqual(const Object& ob) const { return ob.isEqual(*akey); }
  59.  
  60. unsigned LookupKey::hash() const { return akey->hash(); }
  61.  
  62. int LookupKey::compare(const Object& ob) const { return ob.compare(*akey); }
  63.  
  64. void LookupKey::deepenShallowCopy()
  65. {
  66.     akey = akey->deepCopy();
  67. }
  68.  
  69. void LookupKey::dumpOn(ostream& strm) const
  70. {
  71.     strm << className() << '[';
  72.     key()->dumpOn(strm);
  73.     strm << "=>";
  74.     value()->dumpOn(strm);
  75.     strm << "]\n";
  76. }
  77.  
  78. void LookupKey::printOn(ostream& strm) const
  79. {
  80.     key()->printOn(strm);
  81.     strm << "=>";
  82.     value()->printOn(strm);
  83. }
  84.  
  85. const Object* LookupKey::value() const
  86. {
  87.     derivedClassResponsibility("value"); return 0;
  88. }
  89.  
  90. Object* LookupKey::value()
  91. {
  92.     derivedClassResponsibility("value"); return 0;
  93. }
  94.  
  95. Object* LookupKey::value(Object& /*newvalue*/)
  96. {
  97.     derivedClassResponsibility("value"); return 0;
  98. }
  99.  
  100. LookupKey::LookupKey(OIOin& strm)
  101.     : BASE(strm)
  102. {
  103.     akey = Object::readFrom(strm);
  104. }
  105.  
  106. void LookupKey::storer(OIOout& strm) const
  107. {
  108.     BASE::storer(strm);
  109.     akey->storeOn(strm);
  110. }
  111.  
  112. LookupKey::LookupKey(OIOifd& fd)
  113.     : BASE(fd)
  114. {
  115.     akey = Object::readFrom(fd);
  116. }
  117.  
  118. void LookupKey::storer(OIOofd& fd) const
  119. {
  120.     BASE::storer(fd);
  121.     akey->storeOn(fd);
  122. }
  123.